// [[ OnflowGenerator File UUID: 045b6a8b35e0433e96f41c3dfa637736  ]]
package com.itdct.onflow.system.role.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.role.qo.SysRoleEditQo
import com.itdct.onflow.system.role.qo.SysRoleSearchQo
import com.itdct.onflow.system.role.service.SysRoleService
import com.itdct.onflow.system.role.vo.SysRoleDetailVo
import com.itdct.onflow.system.role.vo.SysRoleListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-02 16:19:43
 * @version 1.0
 * @description 系统角色接口控制
 */
@Tag(name = SysRoleController.moduleName)
@RestController
@RequestMapping(value = ["/sysRole"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysRoleController(
    val sysRoleService: SysRoleService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统角色"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysRoleEditQo): RespVo<Long> {
        return sysRoleService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysRoleEditQo): RespVo<Unit> {
        return sysRoleService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysRoleEditQo): RespVo<Unit> {
        return sysRoleService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysRoleSearchQo): RespVo<SysRoleDetailVo> {
        return sysRoleService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysRoleSearchQo): RespPageVo<SysRoleListVo> {
        return sysRoleService.page(qo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "角色名下拉选")
    @PostMapping("/selectNameList.adw")
    fun selectNameList(@RequestBody qo: SysRoleSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysRoleService.selectNameList(qo, getContext())
    }

    @Operation(summary = moduleName + "角色编码下拉选")
    @PostMapping("/selectCodeList.adw")
    fun selectCodeList(@RequestBody qo: SysRoleSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysRoleService.selectCodeList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}